package role.Impl;

import entity.Book;
import entity.Gift;
import factory.GiftFactory;
import role.Role;

/**
 * 用户类
 * 
 * @author yy
 *
 */
public class User {
	private Role role;

	public void login(Role role) {
		this.role = role;
	}

	/**
	 * 图书入库
	 * 
	 * @param book
	 * @param inNum
	 * @return
	 */
	public boolean bookIn(Book book, int inNum) {
		return role.bookIn(book, inNum);
	}

	/**
	 * 图书出库
	 * 
	 * @param book
	 * @param outNum
	 * @return
	 */
	public boolean bookOut(Book book, int outNum) {
		return role.bookOut(book, outNum);
	}

	/**
	 * 显示图书
	 * 
	 * @param book
	 * @param inNum
	 */
	public void showBook(Book[] books) {
		role.showBook(books);
	}

	/**
	 * 添加图书
	 * 
	 * @param book
	 * @param inNum
	 */
	public boolean addBook(Book[] books, Book book) {
		return role.addBook(books, book);
	}

	/**
	 * 结算图书
	 * 
	 * @param book
	 */
	public void checkBook(Book book) {
		role.checkBook(book);
	}

	/**
	 * 购买图书
	 * 
	 * @param book
	 * @param buyNum
	 * @return
	 */
	public Book buyBook(Book book, int buyNum) {
		return role.buyBook(book, buyNum);
	}

	/**
	 * 购买附赠品
	 * 
	 * @param giftId
	 * @return
	 */
	public Gift buyGift(int giftId) {
		return GiftFactory.getGift(giftId);
	}

}
